import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import ElementPlus from 'unplugin-element-plus/vite'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    vueDevTools(),
    ElementPlus({
      useSource: true
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/assets/element.scss" as *;`
      }
    }
  },
  server: {
    host: '0.0.0.0',
    proxy: {
      // 配置跨域
      '/api-c1': {
        target: 'http://10.0.5.142:7106',
        ws: true,
        rewrite: (path) => path.replace(/^\/api-c1/, '')
      }
    }
  }
})
